// When color definition differs for dark and light variant,
// it gets @if ed depending on $variant

@import 'tweaks-temp';
@import 'color-palette';

@function fade($c) {
  @return mix($c, $grey_900, 50%);
}

@function theme($color) {
  @if ($variant == 'light') {
    @if ($theme == 'default') { @return #1A73E8; }
    @if ($theme == 'purple') { @return $purple-400; }
    @if ($theme == 'pink') { @return $pink-400; }
    @if ($theme == 'red') { @return $red-600; }
    @if ($theme == 'orange') { @return $orange-700; }
    @if ($theme == 'yellow') { @return $yellow-700; }
    @if ($theme == 'green') { @return $green-500; }
    @if ($theme == 'teal') { @return $teal-500; }
    @if ($theme == 'grey') { @return $grey-700; }
  } @else {
    @if ($theme == 'default') { @return #3281ea; }
    @if ($theme == 'purple') { @return $purple-300; }
    @if ($theme == 'pink') { @return $pink-300; }
    @if ($theme == 'red') { @return $red-500; }
    @if ($theme == 'orange') { @return $orange-600; }
    @if ($theme == 'yellow') { @return $yellow-a700; }
    @if ($theme == 'green') { @return $green-400; }
    @if ($theme == 'teal') { @return $teal-400; }
    @if ($theme == 'grey') { @return $grey-600; }
  }
}

// Foreground colors
$dark_fg_color:                       rgba($black, 0.87);
$light_fg_color:                      $white;
$button_fg_color:                     if($variant == 'light', rgba($black, 0.62), rgba($white, 0.8)); // extra fg color for raised buttons

$fg_color:                            if($variant == 'light', rgba($black, 0.87), rgba($white, 0.90));
$secondary_fg_color:                  if($variant == 'light', rgba($black, 0.54), rgba($white, 0.70));
$hint_fg_color:                       if($variant == 'light', rgba($black, 0.38), rgba($white, 0.50));
$disabled_fg_color:                   if($variant == 'light', rgba($black, 0.38), rgba($white, 0.50));
$disabled_secondary_fg_color:         if($variant == 'light', rgba($black, 0.26), rgba($white, 0.30));
$track_color:                         if($variant == 'light', rgba($black, 0.20), rgba($white, 0.15));
$visit_color:                         if($variant == 'light', rgba($black, 0.12), rgba($white, 0.10));
$divider_color:                       if($variant == 'light', rgba($black, 0.06), rgba($white, 0.06));

$panel_fg_color:                      if($panel == 'light', rgba($black, 0.88), $white);
$panel_secondary_fg_color:            if($panel == 'light', rgba($black, 0.75), rgba($white, 0.75));
$panel_hint_fg_color:                 if($panel == 'light', rgba($black, 0.55), rgba($white, 0.55));
$panel_disabled_fg_color:             if($panel == 'light', rgba($black, 0.35), rgba($white, 0.45));
$panel_disabled_secondary_fg_color:   if($panel == 'light', rgba($black, 0.26), rgba($white, 0.30));
$panel_track_color:                   if($panel == 'light', rgba($white, 0.50), rgba($white, 0.15));
$panel_divider_color:                 if($panel == 'light', rgba($white, 0.35), rgba($white, 0.10));
$panel_fill_color:                    if($panel == 'light', rgba($white, 0.02), rgba($white, 0.06));

$inverse_fg_color:                    rgba($white, 0.85);
$inverse_secondary_fg_color:          rgba($white, 0.7);
$inverse_hint_fg_color:               rgba($white, 0.5);
$inverse_disabled_fg_color:           rgba($white, 0.5);
$inverse_disabled_secondary_fg_color: rgba($white, 0.3);
$inverse_track_color:                 rgba($white, 0.3);
$inverse_divider_color:               rgba($white, 0.15);
$inverse_fill_color:                  rgba($white, 0.08);

// Background colors
$base_color:                          if($variant =='dark', #202020, #ffffff);
$alt_base_color:                      if($variant =='dark', lighten($base_color, 25%), darken($base_color, 25%));

$dark_bg_color:                       rgba(#202020, 0.9);
$alt_dark_bg_color:                   rgba(#202020, 0.75);
$inverse_bg_color:                    rgba($inverse_fg_color, 0.13);
$button_bg_color:                     if($variant == 'light', $base_color, lighten($base_color, 8%));
$keyboard_bg_color:                   if($variant == 'light', $grey-50, fade($grey-600)); // for gnome-shell keyboard
$alt_keyboard_bg_color:               if($variant == 'light', darken($grey-300, 10%), fade($grey-800)); // for gnome-shell keyboard

$popover_button_bg:                   if($variant == 'light', rgba(white, 0.35), rgba(white, 0.03));
$popover_button_hover:                if($variant == 'light', rgba(black, 0.06), rgba(white, 0.08));
$popover_button_active:               if($variant == 'light', rgba(black, 0.08), rgba(white, 0.12));

@if $outline == 'false' {
  $popover_button_bg:                 if($variant == 'light', rgba(black, 0.06), rgba(white, 0.05));
  $popover_button_hover:              if($variant == 'light', rgba(black, 0.1), rgba(white, 0.12));
  $popover_button_active:             if($variant == 'light', rgba(black, 0.16), rgba(white, 0.15));
}

$card_bg_color:                       if($variant == 'light', mix(white, $base_color, 35%), mix(white, $base_color, 3%));
$card_hover_color:                    if($variant == 'light', mix(black, $base_color, 6%), mix(white, $base_color, 8%));
$card_active_color:                   if($variant == 'light', mix(black, $base_color, 8%), mix(white, $base_color, 12%));

@if $outline == 'false' {
  $card_bg_color:                     if($variant == 'light', mix(black, $base_color, 6%), mix(white, $base_color, 5%));
  $card_hover_color:                  if($variant == 'light', mix(black, $base_color, 10%), mix(white, $base_color, 12%));
  $card_active_color:                 if($variant == 'light', mix(black, $base_color, 16%), mix(white, $base_color, 15%));
}

// Misc colors
$primary_color:                       theme(color);
$alt_primary_color:                   darken($primary_color, 3%);
$accent_color:                        lighten($primary_color, 3%);

$panel_bg:                            if($panel == 'light', #f3f3f3, #202020);
$panel_bg_color:                      if($opacity == 'default', if($panel == 'light', rgba(white, 0.5), rgba(black, 0.5)), $panel_bg);
$menu_bg_color:                       if($opacity == 'default', rgba($base_color, 0.97), $base_color);
$system_bg_color:                     #222222;

$link_color:                          $primary_color;
$visited_link_color:                  if($variant == 'light', $purple-500, $purple-200);

$warning_color:                       $orange_a700;
$error_color:                         $deep_orange_a700;
$success_color:                       $green_a700;

$suggested_color:                     $accent_color;
$destructive_color:                   $red_a200;

$info_bg_color:                       $green_400;
$question_bg_color:                   $blue_400;
$warning_bg_color:                    $orange_400;
$error_bg_color:                      $red_400;

$border_color:                        if($variant == 'light', rgba($black, 0.12), rgba($white, 0.1));
$md_border_color:                     if($variant == 'light', transparent, $divider_color);
$icon_border_color:                   rgba($black, 0.12);
$panel_border_color:                  if($variant == 'light', rgba($black, 0.05), rgba($black, 0.12));
$popover_button_border:               if($variant == 'light', rgba(black, 0.12), rgba(white, 0.05));

$highlight_color:                     if($variant == 'light', rgba($white, 0.35),  rgba($white, 0.1));
$icon_highlight_color:                rgba($white, 0.1);
$panel_highlight_color:               if($panel == 'light', rgba($white, 0.35),  rgba($white, 0.1));
